package com.flowerSystem.util;

import lombok.Data;

import java.io.Serializable;

@Data
public class ResponseResult<T> implements Serializable {
    private int code;
    private String message;
    private T data;

    /**成功响应*/
    public static <T> ResponseResult<T> ok(T data){
        ResponseResult result = new ResponseResult();
        result.setCode(1);
        result.setMessage("ok...");
        result.setData(data);
        return result;
    }

    /**失败响应*/
    public static ResponseResult fail(){
        ResponseResult result = new ResponseResult();
        result.setCode(0);
        result.setMessage("fail...");
        return result;
    }

    public static <T> ResponseResult<T> error(T data){
        ResponseResult result = new ResponseResult();
        result.setCode(0);
        result.setMessage("error...");
        return result;
    }

    public static <T> ResponseResult<T> success(String url){
        ResponseResult result = new ResponseResult();
        result.setData(url);
        result.setCode(1);
        result.setMessage("success...");
        return result;
    }

    public static <T> ResponseResult<T> success(T data){
        ResponseResult result = new ResponseResult();
        result.setData(data);
        result.setCode(1);
        result.setMessage("success...");
        return result;
    }
}


